package com.xyd.servlet;

import com.xyd.entity.News;
import com.xyd.service.NewsService;
import com.xyd.service.impl.NewsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 赵瑞硕
 * 查看热点新闻详情
 */
@WebServlet("/newsSearchVisit")
public class NewsSearchVisitServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String enIds=request.getParameter("enId");
        long enId=Long.parseLong(enIds);
        NewsService newsService=new NewsServiceImpl();
        News newsList= newsService.visitSearchNews(enId);
        request.setAttribute("newsList",newsList);
        request.getRequestDispatcher("news-view.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
